export const autoGrow = (val) => {
  let num = 0,
    text = ''
  const targetNum = parseInt(val.replace(/,/g, ''))
  const timer = setInterval(() => {
    if (num >= targetNum) {
      clearInterval(timer)
    } else {
      num += Math.ceil(targetNum / 100)
      text = num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
      console.log(text)
      return text
    }
  }, 10)
}

// 数字或字符串 转千分位
export const thousandSplit = (number) => {
  // console.log(number, '-=-')
  let str = String(number) // 数字转换为字符串
  let remainder = str.length % 3 // 计算字符串除3的余数
  let res = '' // 保存插入千位符后的结果
  for (let i = remainder; i < str.length; i = i + 3) {
    res = res + ',' + str.substr(i, 3)
  }
  // 余数为0，去掉第一个字符','  余数不为0，从下标0截取remainder个字符并拼接到res前面
  remainder === 0 ? (res = res.substr(1)) : (res = str.substr(0, remainder) + res)
  return res
}
